package com.wqtz.chechai.view.activities;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.wqtz.chechai.R;
import com.wqtz.chechai.adapter.AdSearchStatusAdapter;
import com.wqtz.chechai.adapter.SearchResultAdapter;
import com.wqtz.chechai.base.BaseActivity;
import com.wqtz.chechai.base.lvbaseadapter.ViewHolder;
import com.wqtz.chechai.bean.OrderBean;
import com.wqtz.chechai.bean.Status;
import com.wqtz.chechai.presenter.BasePresent;
import com.wqtz.chechai.utils.ToastUtils;

import org.w3c.dom.ls.LSException;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2017/2/23 14:43
 */

public class SearchByStatusActivity extends BaseActivity implements AdSearchStatusAdapter.QuoteResItemClickCallBack {
	@BindView(R.id.iv_back)
	ImageView mIvBack;
	@BindView(R.id.tv_title)
	TextView mTvTitle;
	@BindView(R.id.lv)
	ListView mLv;

	private List<Status> datas;
	List<OrderBean> data;//模拟数据
	private AdSearchStatusAdapter mAdapter;
	private int nowPosition; //当前选中位置

	@Override
	public void init() {
		nowPosition = getIntent().getIntExtra("position",0);
		ButterKnife.bind(this);
		mTvTitle.setText("状态");
		datas = new ArrayList<>();
		mAdapter = new AdSearchStatusAdapter(R.layout.item_adsearch_status,nowPosition);
		mLv.setAdapter(mAdapter);
		mAdapter.setClickListen(this);
	}

	@Override
	public void loadData() {
		datas.clear();
		String status[] = new String[]{"全部","等待审核","已报价","未通过"};
		for (int i = 0; i <status.length ; i++) {
			Status s = new Status();
			s.type=i;
			s.status = status[i];
			if(nowPosition==i){
				s.isChecked=true;
			}else {s.isChecked=false;}
			datas.add(s);
		}
		mAdapter.addData(datas);
	}

	@Override
	public int setContentViews() {
		return R.layout.activity_adsearch_status;
	}

	@Override
	public BasePresent createPresenter() {
		return null;
	}


	@OnClick(R.id.iv_back)
	public void onClick() {
		finish();
	}

	@Override
	public void quoteResItemClickCallBack(int positon) {
		Intent intent = new Intent();
		intent.putExtra("status",datas.get(positon).status);
		intent.putExtra("position",positon);
		intent.putExtra("type",datas.get(positon).type);
		setResult(RESULT_OK,intent);
		finish();
	}
}


